if(NOT OTB_BUILD_DEFAULT_MODULES)
  message(FATAL_ERROR "BUILD_EXAMPLES requires OTB_BUILD_DEFAULT_MODULES to be ON")
endif()
# We also need to prevent any OTB_USE_XXX option to be OFF (except mapnik and openjpeg)
# For now we parse module activation list and test if option is ON. If not the cmake configuration stop.
#TODO We should provide a better mechanism here wich will deactivate only examples required by deactivated options.
foreach (_activationOption ${OTB_MODULE_ACTIVATION_OPTION_LIST})
  if(NOT ${_activationOption} AND NOT "x${_activationOption}" STREQUAL "xOTB_USE_MAPNIK" AND NOT "x${_activationOption}" STREQUAL "xOTB_USE_OPENJPEG")
    message(FATAL_ERROR "BUILD_EXAMPLES requires ${_activationOption} to be ON")
  endif()
endforeach()

find_package(OTB REQUIRED)
include(${OTB_USE_FILE})
# TODO : build as standalone project

set(OTB_TEST_DRIVER otbTestDriver)

if(BUILD_APPLICATIONS)
  add_subdirectory(Application)
endif()
add_subdirectory(BasicFilters)
add_subdirectory(ChangeDetection)
add_subdirectory(Classification)
add_subdirectory(DataRepresentation)
add_subdirectory(DimensionReduction)
add_subdirectory(DisparityMap)
add_subdirectory(FeatureExtraction)
add_subdirectory(Filtering)
add_subdirectory(Fusion)
add_subdirectory(Hyperspectral)
add_subdirectory(Installation)
add_subdirectory(IO)
add_subdirectory(Iterators)
add_subdirectory(Learning)
add_subdirectory(Markov)
add_subdirectory(MultiScale)
add_subdirectory(OBIA)
add_subdirectory(Patented)
add_subdirectory(Projections)
add_subdirectory(Radiometry)
add_subdirectory(Registration)
add_subdirectory(Segmentation)
add_subdirectory(Simulation)
add_subdirectory(Tutorials)
